﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace PanoramaTestApp
{
    public partial class SettingsPage : PhoneApplicationPage
    {
        public SettingsPage()
        {
            InitializeComponent();
            DataContext = App.SettingsViewModel;
            this.Loaded += new RoutedEventHandler(SettingsPage_Loaded);
            
        }

        void SettingsPage_Loaded(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigating += new System.Windows.Navigation.NavigatingCancelEventHandler(NavigationService_Navigating);
        }

        void NavigationService_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e)
        {
            if(e.NavigationMode == NavigationMode.Back)
                App.ViewModel.IsDataLoaded = false;
        }

        private void OkClick(object sender, System.Windows.RoutedEventArgs e)
        {
            
            NavigationService.GoBack();
        }

        private void GoToLocksClick(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/LogFilesView.xaml", UriKind.Relative));
        }
    }
}